home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-06-19 | 3.0 KB | 124 lines | [TEXT/CWIE] |
- //
- // UGrayscaleAppearance.cp
- //
- // Utilities for supporting the Apple Grayscale Appearance for System 7.5
- //
- //
- // Copyright © 1996 by James Jennings. All rights reserved.
- //
-
- // To Check: are these being disposed of?
-
- #include "UGrayscaleAppearance.h"
-
- void UGrayscaleAppearance::FrameRect( const Rect &inFrame,
- EGAColor inTopLeft, EGAColor inBottomRight, EGAColor inCorners)
- { // Draw a frame that gives the "beveled" look.
- // inTopLeft is the color of the top and left edges.
- // inBottomRight is the color of the bottom and right edges.
- // inCorners is the color of the pixels in the bottom-left and top-right corners.
-
- // width and height of the interior of the frame
- Int16 width = inFrame.right - inFrame.left - 2;
- Int16 height = inFrame.bottom - inFrame.top - 2;
-
- Assert_( width >= 0 && height >= 0 );
-
- ::PenSize( 1, 1 );
-
- ::MoveTo( inFrame.left, inFrame.bottom - 1 );
- SetForeColor( inCorners );
- ::Line( 0, 0 );
-
- SetForeColor( inTopLeft );
- ::Move( 0, -1 );
- ::Line( 0, - height );
- ::Line( width, 0 );
-
- SetForeColor( inCorners );
- ::Move( 1, 0 );
- ::Line( 0, 0 );
-
- SetForeColor( inBottomRight );
- ::Move( 0, 1 );
- ::Line( 0, height );
- ::Line( - width, 0 );
-
- }
-
- void UGrayscaleAppearance::PrimaryGroupRect(
- Rect inFrame, EGAColor inTopLeft, EGAColor inBottomRight )
- {
- ::PenSize( 1, 1 );
-
- inFrame.top ++;
- inFrame.left ++;
- SetForeColor( inBottomRight );
- ::FrameRect( &inFrame );
-
- ::OffsetRect( &inFrame, -1, -1 );
- SetForeColor( inTopLeft );
- ::FrameRect( &inFrame );
-
- // fill in the corners
- SetForeColor( inBottomRight );
- ::MoveTo( inFrame.left, inFrame.bottom );
- ::Line( 0, 0 );
-
- ::MoveTo( inFrame.right, inFrame.top );
- ::Line( 0, 0 );
- }
-
- void CGABaseAttachment::ExecuteSelf( MessageT inMessage, void *ioParam)
- { // Call the correct draw routine depending on the screen depth.
-
- Assert_( ioParam != nil );
-
- StColorState theSavedState;
-
- Rect theFrame = *(Rect *)ioParam;
-
- // The device loop sets the clip rect, so we need to tell it
- // the rect we plan to draw to.
- Rect clipRect = theFrame;
- AdjustClipRect( clipRect );
-
- StDeviceLoop devices(clipRect);
- Int16 depth;
-
- while (devices.NextDepth(depth)) {
- StColorPenState savePenState; // Will save and restore pen state
- savePenState.Normalize();
-
- if (depth > 3) {
- DrawColor( theFrame ); // we have at least 16 colors
- } else {
- DrawBlackAndWhite( theFrame );
- }
- }
-
- }
-
- void CGAPaneAttachment::DrawColor( Rect &inFrame )
- {
- FrameRect( inFrame, ga_Hilite, ga_Shadow, ga_Hilite );
- ::InsetRect( &inFrame, 1, 1 );
- PaintRect( inFrame, ga_Background );
- }
-
- void CGADeepPaneAttachment::DrawColor( Rect &inFrame )
- { // The color scheme of a movable modal dialog. (Not counting the black outline.)
- FrameRect( inFrame, ga_2, ga_10, ga_2 );
- ::InsetRect( &inFrame, 1, 1 );
- FrameRect( inFrame, ga_White, ga_6, ga_2 );
- ::InsetRect( &inFrame, 1, 1 );
- PaintRect( inFrame, ga_Background );
- }
-
- void CGATextFieldAttachment::DrawColor( Rect &inFrame )
- {
- EraseRect( inFrame, ga_White );
- ::InsetRect( &inFrame, -1, -1 );
- FrameRect( inFrame, ga_5, ga_White, ga_Background );
- }
-